package com.i2863.receipt.entity;

import com.alibaba.fastjson.annotation.JSONField;
import com.i2863.receipt.util.BaseEntity;
import lombok.Getter;
import lombok.Setter;

import javax.persistence.*;
import java.util.Date;
import java.util.List;

/**
 * 活动表实体
 * Created by Administrator on 2018/6/7.
 */
@Entity
@Table(name="d_activity")
@Getter
@Setter
public class Activity extends BaseEntity{

    /**
     * 活动名称
     */
    @Column(name = "name",nullable = false)
    private String name;

    /**
     * 期数
     */
    @Column(name = "num",nullable = false)
    private Integer num;

    /**
     * 入围人数
     */
    @Column(name = "enroll_num",nullable = false)
    private int enrollNum;

    /**
     * 内场人数
     */
    @Column(name="inside_num",nullable = false)
    private int insideNum;

    /**
     * 外场人数
     */
    @Column(name = "outside_num",nullable = false)
    private int outsideNum;

    /**
     * 从未入围中选出的人数
     */
    @Column(name = "reselection_num",nullable = false)
    private int reselectionNum;

    /**
     * 档期发票金额最低限制
     */
    @Column(name = "amount_low",nullable = false)
    private Double amountLow;

    /**
     * 活动状态 0未开始抽奖 1以抽出入围 2从入围抽出场内场外 3结束抽奖
     */
    @Column(name = "activity_status",nullable = false)
    private Integer activityStatus;

    /**
     * 开始时间
     */
    @Column(name = "starttime",nullable = false)
    private Date startTime;

    @Column(name = "endtime",nullable = false)
    private Date endTime;

    /**
     * 所属站点
     */
    @ManyToOne(fetch = FetchType.LAZY)
    @JoinColumn(name="site_id")
    private Site site;

    /**
     * 活动下的发票集合
     */
    @JSONField(serialize = false)
    @OneToMany(fetch= FetchType.LAZY,mappedBy="activity")
    private List<Receipt> receiptList;

    /**
     * 活动下的中奖集合
     */
    @JSONField(serialize = false)
    @OneToMany(fetch = FetchType.LAZY,mappedBy = "activity")
    private List<Winner> winngList;

    /**
     * 抽奖未开始
     */
    public static Integer NOTSTARTED = 0;

    /**
     * 抽出入围人员ED
     */
    public static Integer STARTED = 1;

    /**
     * 抽出场内外
     */
    public static Integer SECOND_ROUND = 2;

    /**
     * 抽奖活动结束
     */
    public static Integer END = 3;

}
